realtek: pcs: add helpers for even, odd, neighbor SerDes
authorJonas Jelonek <[email protected]>
Sat, 13 Dec 2025 10:16:21 +0000 (10:16 +0000)
committerRobert Marko <[email protected]>
Tue, 16 Dec 2025 12:37:32 +0000 (13:37 +0100)
Add dedicated helpers to get references to even, odd and neigbor SerDes
if needed. This should replace the various calculations scattered
throughout the code, providing a unified way to work with adjacent
SerDes.

Signed-off-by: Jonas Jelonek <[email protected]>
Link: https://github.com/openwrt/openwrt/pull/21146
Signed-off-by: Robert Marko <[email protected]>
target/linux/realtek/files-6.12/drivers/net/pcs/pcs-rtl-otto.c

index 566e79962ca96d68fcd3746ba43b68da40f0a557..435a74af7cbd3a2c473eca3824dc809195f57754 100644 (file)
@@ -239,6 +239,27 @@ static int rtpcs_sds_modify(struct rtpcs_ctrl *ctrl, int sds, int page, int regn
                                  mask, set);
 }
 
+__maybe_unused
+static struct rtpcs_serdes *rtpcs_sds_get_even(struct rtpcs_serdes *sds)
+{
+       u32 even_sds = sds->id & ~1;
+       return &sds->ctrl->serdes[even_sds];
+}
+
+__maybe_unused
+static struct rtpcs_serdes *rtpcs_sds_get_odd(struct rtpcs_serdes *sds)
+{
+       u32 odd_sds = sds->id | 1;
+       return &sds->ctrl->serdes[odd_sds];
+}
+
+__maybe_unused
+static struct rtpcs_serdes *rtpcs_sds_get_neighbor(struct rtpcs_serdes *sds)
+{
+       u32 nb_sds = sds->id ^ 1;
+       return &sds->ctrl->serdes[nb_sds];
+}
+
 static int rtpcs_regmap_read_bits(struct rtpcs_ctrl *ctrl, int base, int bithigh, int bitlow)
 {
        int offset = base + (bitlow / 32) * 4;